package com
{

		import flash.net.URLRequest;
		import flash.display.*;
		import flash.events.*;
		import flash.media.*;
		public class Music extends Sprite 
		{
			private var sound:Sound;
			//private var _stage;
			private var channel:SoundChannel=new SoundChannel();
			private var wei:int;
			
			public function Music(url:String) 
			{
				url = Engine.assetMuiscPath + url;
				sound=new Sound ();
				sound.addEventListener(Event.COMPLETE,completeHandler);
				sound.load(new URLRequest(url));
				//channel = sound.play(0,int.MAX_VALUE);
				//channel.stop();
			}
			private function completeHandler(event:Event):void 
			{
				//dispatchEvent(new musicEvent(musicEvent.COMPLETE));
				channel = sound.play(0,int.MAX_VALUE);
			}
			public function stop():void 
			{
				wei = channel.position;
				channel.stop();
			}
			public function resume():void 
			{
				channel = sound.play(wei);
			}
			public function clearChannel():void
			{
				if (channel != null) 
				{
					channel.stop();
				}
				sound = new Sound();
				channel = new SoundChannel();
			}
			//public function seek(can) 
			//{
			//	channel.stop();
			//	channel=sound.play(can);
			//}
			public function get time():int 
			{
				return channel.position;
			}
			public function get total():int 
			{
				return sound.length;
			}
			public override function set soundTransform(value:SoundTransform):void 
			{
				channel.soundTransform = value;
				
			}
		}
}